home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Str / c / strnicmpcr < prev   
Text File  |  1995-07-08  |  1KB  |  44 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Str.strnicmpcr.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (06 Mar 1994)
  14.     Purpose: Version of strnicmp that works on CR-terminated strings.
  15. */
  16.  
  17. /* For size_t */
  18. #include <stdlib.h>
  19.  
  20. #include <ctype.h>
  21.  
  22. #include "DeskLib:Str.h"
  23.  
  24. extern int strnicmpcr(char *s1, char *s2, size_t n)
  25. {
  26.   char ch1 = 0, 
  27.        ch2 = 0;
  28.  
  29.   for(;;)
  30.   {
  31.     if ((n == 0) || ((*s1 < 32) && (*s2 < 32)))
  32.       return 0; /* s1 and s2 are equal */
  33.       
  34.     ch1 = toupper(*s1);
  35.     ch2 = toupper(*s2);
  36.  
  37.     if (ch1 != ch2)
  38.       return (int) (ch1 - ch2);
  39.     s1++;
  40.     s2++;
  41.     n--;
  42.   }
  43. }
  44.